<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/11
  Time: 19:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>个人信息修改</title>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        input{
            background: none;
            border: none;
            height: 50px;
            width: 320px;
            font-size: 16px;
        }
        .all{
            width: 850px;
            max-height: 550px;
            overflow: auto;
            border: 2px solid red;
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
            margin-top: 25px;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: red;
            margin-bottom: 10px;
        }
        .form{
            width: 400px;
            margin: 0 auto;
        }
        .form .list{
            width: 100%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            margin-bottom: 10px;
            border: 2px solid red;
        }
        .form .list .float,.input{
            float: left;
            height: 50px;
            line-height: 50px;
        }
        .float{
            width: 80px;
            text-align: center;
        }
        .input{
            width: 320px;
        }
        button{
            width: 80px;
            height: 30px;
            line-height: 30px;
            background: #a39933;
            border: none;
            border-radius: 10px;
            display: block;
            margin: 0 auto;
            margin-top: 10px;
            color: #ffffff;
            cursor: pointer;
        }
        button:hover{
            background: red;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
<article class="all">
    <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;个人信息修改</div>
    <div class="form">
        <div class="list">
            <div class="float uname">
                用户名：
            </div>
            <div class="input">
                <input type="text" id="username" placeholder="请输入用户名" value="${sessionScope.admin.adminUsername}">
            </div>
        </div>
        <div class="list">
            <div class="float pass">
                密码：
            </div>
            <div class="input">
                <input type="password" id="password" placeholder="请输入密码" value="${sessionScope.admin.adminPassword}">
            </div>
        </div>
        <div class="list">
            <div class="float emai">
                邮件地址：
            </div>
            <div class="input">
                <input type="text" id="email" placeholder="请输入邮件地址" value="${sessionScope.admin.adminEmail}">
            </div>
        </div>
        <div class="list">
            <button type="button" id="btn">修改</button>
        </div>
        <div class="list" id="text" style="border: none;display: none;color: red">

        </div>
    </div>
</article>
<script>
    $(document).ready(function () {
         $("#btn").click(function () {
              var id = "${sessionScope.admin.adminId}";
              var username = $.trim($("#username").val());
              var password = $.trim($("#password").val());
              var email = $.trim($("#email").val());
              var data = "id="+id+"&username="+username+"&password="+password+"&email="+email;
              var sb = /^[0-9a-zA-Z]+@+[0-9a-zA-Z]+\.com(\.cn)?$/;
              if(username == ""){
                  $("#text").css("display","block").html("<h2>用户名不能为空!</h2>");
              }else if(password == ""){
                  $("#text").css("display","block").html("<h2>密码不能为空!</h2>");
              }else if(email == ""){
                  $("#text").css("display","block").html("<h2>邮箱不能为空!</h2>");
              }else if(!sb.test(email)){
                  $("#text").css("display","block").html("<h2>邮箱格式有误!</h2>");
              }else{
                   $.ajax({
                       url:"/AdminLoginServlet?type=upadmin",
                       type:"post",
                       data:data,
                       dataType:"text",
                       async:true,
                       success:function (data) {
                           if(data =="1"){
                               alert("修改成功！");
                               window.location.href="ShowMydata.jsp";
                           }else{
                               alert("修改失败！");
                           }
                       },
                       error:function (error) {
                            alert("系统异常！");
                       }
                   })
              }
         })
    })
</script>
</body>
</html>
